package com.xmy.study.util;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class CommonUtil {

    /**
     * 判断两个值的季度相差多少
     */
    public static Integer diffQuarter(Map<String,Integer> map){
        Integer oldYear = map.get("oldYear");
        Integer oldNum = map.get("oldNum");
        Integer newYear = map.get("newYear");
        Integer newNum = map.get("newNum");

        Integer diffYear = newYear - oldYear;
        Integer diffNum = (newYear - oldYear) * 4 + newNum - oldNum;

        return diffNum;
    }

    /**
     * 获取学段id
     * @param yearClassId
     * @return
     */
    public static Integer getGradeSectionId(Integer yearClassId){
        //yearClassId:少儿:0,1,2;小学:3,4,5,6;初中7,8,9;高中:10,11,12

        Integer[][] arr={{0,1,2},{3,4,5,6},{7,8,9},{10,11,12}};
        Integer rs = null;
        for (int i=0;i<arr.length;i++){
            Set<Integer> set = new HashSet<Integer>(Arrays.asList(arr[i]));
            if (set.contains(yearClassId)){
                rs = i;
                break;
            }
        }
        return rs;
    }
}
